//package com.jasper;
//
//import java.io.ByteArrayOutputStream;
//import java.io.File;
//import java.util.HashMap;
//import java.util.Map;
//
//import org.apache.commons.io.FileUtils;
//
//import net.sf.jasperreports.engine.JasperCompileManager;
//import net.sf.jasperreports.engine.JasperFillManager;
//import net.sf.jasperreports.engine.JasperPrint;
//import net.sf.jasperreports.engine.export.HtmlExporter;
//import net.sf.jasperreports.engine.export.JRPdfExporter;
//import net.sf.jasperreports.engine.export.JRXlsExporter;
//import net.sf.jasperreports.export.Exporter;
//
//public class ReportFormController {
//
//    private static final int OUTPUT_BYTE_ARRAY_INITIAL_SIZE = 51200;
//
//    public static void main(String[] args) throws Exception {
//        Map<String, Object> parameters = new HashMap<String, Object>();
//
//        Exporter<?, ?, ?, ?> exporter = null;
//
//        String fileSuffix = "html";
//
//        if ("xls".equalsIgnoreCase(fileSuffix)) {
//            exporter = new JRXlsExporter();
//        } else if ("html".equalsIgnoreCase(fileSuffix)) {
//            exporter = new HtmlExporter();
//        } else {
//            exporter = new JRPdfExporter();
//        }
//
//        String template = Thread.currentThread().getContextClassLoader().getResource("report1.jrxml").getPath();
//        String jasper = template.replace(".jrxml", ".jasper");
//
//        JasperCompileManager.compileReportToFile(template, jasper);
//
//        DBHelper dbh = new DBHelper("db2");
//
//        @SuppressWarnings("unused")
//        JasperPrint print = JasperFillManager.fillReport(jasper, parameters, dbh.connect());
//
//        dbh.close();
//
//        ByteArrayOutputStream baos = new ByteArrayOutputStream(OUTPUT_BYTE_ARRAY_INITIAL_SIZE);
//
//        exporter.exportReport();
//
//        FileUtils.writeByteArrayToFile(new File("D:/edoc." + fileSuffix), baos.toByteArray());
//
//        baos.close();
//    }
//
//}